﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Collections.ObjectModel;
using for7raid.vk;

namespace for7raid.vkGroupExplorer
{
    public class CityConverter: IMultiValueConverter
    {

        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var list = values[0] as ObservableCollection<City>;

            if (values[1] == null || values[1] == "")
                return "";

            var cityid = int.Parse(values[1].ToString());

            var city = list.FirstOrDefault(i => i.Id == cityid);

            return city != null ? city.Name : "";

        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
